package ApplicationStart.Swagger2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


//url => http://10.1.1.138:9082/swagger-ui.html
@Configuration("Swinger2 Config")
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket newAPI(){
        //return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().paths(PathSelectors.any()).build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        docket.enable(true);
        docket.apiInfo(this.apiInfo()).select().paths(PathSelectors.any()).build();
        return docket;
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Spark and Scala, Spring test platform")
                .description("在这里可以浏览项目的所有接口，并且提供相关测试工具")
                .license("China Red Star License Version 1.0")
                .licenseUrl("http://www.djava.top")
                .version("1.0")
                .build();
    }
}
